# n1 = 255
# n2 = 1000

# print(hex(n1))
# print(hex(n2))


# def my_abs(x):
#     if x >= 0:
#         return x
#     else:
#         return -x
#
#
# my_absnum = my_abs(10)
# print(my_absnum)


# def my_abs(x):
#     if not isinstance(x, (int, float)):
#         raise TypeError('bad operand type')
#     if x >= 0:
#         return x
#     else:
#         return -x
#
#
# print(my_abs("a"))
# import math
#
#
# def quadratic(a, b, c):
#     m = b ** 2 - 4 * a * c
#     if m > 0:
#         x1 = (-b + math.sqrt(m)) / (2 * a)
#         x2 = (-b - math.sqrt(m)) / (2 * a)
#         return x1, x2
#     else:
#         return "no answer"
#
#
# # 测试:
# print("quadratic(2, 3, 1) =", quadratic(2, 3, 1))
# print("quadratic(1, 3, -4) =", quadratic(1, 3, -4))
#
# if quadratic(2, 3, 1) != (-0.5, -1.0):
#     print('测试失败')
# elif quadratic(1, 3, -4) != (1.0, -4.0):
#     print('测试失败')
# else:
#     print('测试成功')

# def power(x, n=2):
#     s = 1
#     while n > 0:
#         n = n - 1
#         s = s * x
#     return s
#
#
# a = power(2, 3)
# print(a)

# def add_end(L=None):
#     if L is None:
#         L = []
#     L.append('END')
#     return L
#
#
# print(add_end())

# def calc(*numbers):
#     sum = 0
#     for n in numbers:
#         sum = sum + n * n
#     return sum
#
#
# print(calc(1, 2, 3, 4))

# 1*1 2*2*2 3*3*3*3
def mul(*xx):
    j = 1
    for i in xx:
        j = j * i
    return j


# 测试
print('mul(5) =', mul(5))
print('mul(5, 6) =', mul(5, 6))
print('mul(5, 6, 7) =', mul(5, 6, 7))
print('mul(5, 6, 7, 9) =', mul(5, 6, 7, 9))
if mul(5) != 5:
    print('测试失败!')
elif mul(5, 6) != 30:
    print('测试失败!')
elif mul(5, 6, 7) != 210:
    print('测试失败!')
elif mul(5, 6, 7, 9) != 1890:
    print('测试失败!')
else:
    try:
        mul()
        print('测试失败!')
    except TypeError:
        print('测试成功!')
